//
//  oneImageTableViewCell.m
//  SeseNews
//
//  Created by lanou3g on 15/7/22.
//  Copyright (c) 2015年 Sese工作室. All rights reserved.
//
#define width1 375
#define height1 667
#import "oneImageTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation oneImageTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //        self.width=self.frame.size.width;
        //        self.height=self.frame.size.height;
        //布局控件
        self.image=[[UIImageView alloc]initWithFrame:CGRectMake(8, 8, [[UIScreen mainScreen] bounds].size.width*0.35, [[UIScreen mainScreen] bounds].size.height*0.84*0.18)];
        
        [self addSubview:self.image];
        //label的布局
        self.titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(146, 8,[[UIScreen mainScreen] bounds].size.width*0.61,[[UIScreen mainScreen] bounds].size.height*0.42*0.18)];
        self.titleLabel.numberOfLines=0;
        self.titleLabel.font=[UIFont systemFontOfSize:17];
        
        [self addSubview:self.titleLabel];
        self.commentsLaebl=[[UILabel alloc]initWithFrame:CGRectMake(280, 86, 0.14*[[UIScreen mainScreen] bounds].size.width, 0.18*0.21*[[UIScreen mainScreen] bounds].size.height)];
        self.commentsLaebl.font=[UIFont systemFontOfSize:17];
        self.commentsLaebl.textAlignment=NSTextAlignmentRight;
        [self addSubview:self.commentsLaebl];
        
        self.textLbel=[[UILabel alloc]initWithFrame:CGRectMake(335, 88,35,0.15*0.21*height1)];
        self.textLbel.text = @"跟帖";
        [self addSubview:self.textLbel];
    }
    return self;
    
}
//重写set方法赋值
-(void)setPassValue:(model *)passValue{
    _passValue=passValue;
    //使用第三方异步下载图片
    [self.image sd_setImageWithURL:[NSURL URLWithString:self.passValue.thumbnail]];
    self.titleLabel.text=self.passValue.title;
    //判断评论是否过万
    CGFloat count=[self.passValue.commentsall intValue];
    NSString *disPlayCount;
    if (count>10000) {
        disPlayCount=[NSString stringWithFormat:@"%.1f万",count/10000];
    }else{
        disPlayCount=[NSString stringWithFormat:@"%.f",count];
    }
    if ([disPlayCount isEqualToString:@"0"]) {
        disPlayCount=nil;
    }
    self.commentsLaebl.text=disPlayCount;
}

+(CGFloat)heightForRow:(model*)model{
    if (model.imageUrl1!=nil) {
        
        return [[UIScreen mainScreen] bounds].size.height*0.224;
    }
    else {
        return [[UIScreen mainScreen] bounds].size.height*0.18;
    }
    return 0;
}














- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
